/**
 * @author peter
 * This is a resource which implements file list, create load and save using only hardwired examples
 */
dojo.require("dojo.data.ItemFileReadStore");
dojo.provide("bunkai.bk_resource_examples");
dojo.declare("bunkai.bk_resource_examples", bunkai.bk_resource,
{
	tabcontainer: "", // The dojo.tabcontainer where we'll create a new tab for ourselves
	contentpane: "",  // Our tab
	constructor: function(tc)
	{
		this.tabcontainer = tc;
		console.log("examples resource tabcontainer id is "+tc+" obj is "+this.tabcontainer);
		this.resource_id = "Examples"; // Defined in superclass 
	},
	
	// Called from framework, when we're selected by user
	show: function()
	{
		if(!this.contentpane)
		{
			var tabdiv = document.createElement('div');
			tabdiv.id = "examples_resources";
			
			// Fill up with stuff
			var data = {data: {  label: 'name',
	            identifier: 'id',
	            items: [
	                { id:1, name:'SplitPane example', type:'category'},
	                { id:2, name:'Charting example', type: 'category'},
	                { id:3, name:'Tree example', type: 'category'}
	            ]
	        }};
	   		var treediv = document.createElement('div');
			treediv.id = "examples_resource-tree_div";
			treediv.style.height = "100%";
			treediv.style.width = "100%";
			tabdiv.style.height = "100%";
			tabdiv.style.width = "100%";
			tabdiv.appendChild(treediv);
	    	var store=new dojo.data.ItemFileReadStore(data);
	       
  			// Add the whole thing
			this.contentpane = new dijit.layout.LayoutContainer({title: this.getName()}, tabdiv);
			this.tabcontainer.addChild(this.contentpane);
			var tree = new dijit.Tree({label: "Examples", store: store}, treediv);
			this.contentpane.addChild(tree);			
			//this.tabcontainer.selectChild(this.contentPane);			
		}		
		this.contentpane.refresh();
		this.tabcontainer.selectChild(this.contentpane);
		//this.contentpane.focus();
	},
	
	getName: function()
	{
		return this.resource_id;
	},
				
	// called by framework
	saveFromFramework: function(data, id)
	{
			
	}
	
});